/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package exercises.day01.pt3;

import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.text.DecimalFormat;
import java.util.Scanner;

/**
 * MyFirstJava
 *
 * @author (jaice)
 * @version 0.1 (may 28, 2012)
 * 
 * b. Implement a program that reads in a list of integers (up to 20 of them), and 
 * then performs a sequence of operations on them. The minimum operations that your 
 * program must perform are as follows:		
 * i. Sum: print out their sum of the integers in your array	
 * ii. Print: print out the array	
 * iii. Print backward: print out the array in reverse order
 *
 * 
 */
public class TwentyInteger {

    public static void main(String args[]) {
        //declare variable
        int[] list = new int[20];
        int sum = 0;


        //declare scanner
        Scanner sc = new Scanner(System.in);


        for (int x = 0; x < 20; x++) {
            //get integer
            System.out.println("Enter number " + (x + 1));
            list[x] = sc.nextInt();
        }

        for (int x = 0; x < 20; x++) {
            //prints list
            System.out.print(list[x]);
            //prints list in reverse
            System.out.print("\t" + list[19 - x]);

            System.out.println();
            //get sum
            sum += x;
        }

        //prints sum
        System.out.print("\n\nSum of array is " + sum);


    }
}
